package com.impl.SystemCore;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;

import com.xlh.outside.MainActivity;
import com.xlh.outside.WzApplication;

/**
 *
 * android 在从sdk14 开始为我们提供了一个新的api
 *
 * 用于检测app 中activity 的生命周期，正好我们app 的minSdkVersion 已经设置为 14 了。
 * 所以现在我们可以使用ActivityLifecycleCallbacks来 监听app 是否运行在后台的行为了。
 *
 * Created by fang on 2017-11-19.
    */
public  class ActivityLifecycleListener implements Application.ActivityLifecycleCallbacks {

    private int refCount = 0;
    private Application application;


    public ActivityLifecycleListener(Application application){
        this.application = application;
    }

    @Override
    public void onActivityCreated(Activity activity, Bundle savedInstanceState) {

    }

    @Override
    public void onActivityStarted(Activity activity) {
        Log.e("Application","=====================================我在前台了");
      //  ((WzApplication)application).setBackRunning(false);
    }

    @Override
    public void onActivityResumed(Activity activity) {
       // ((WzApplication)application).setBackRunning(false);
      //  Log.e("Application","=====================================我在前台了");
       // ((WzApplication)application).setBackRunning(false);
    }

    @Override
    public void onActivityPaused(Activity activity) {

    }

        @Override
        public void onActivityStopped(Activity activity) {
            Log.e("Application","==========================================我在后台了");
            //((WzApplication)application).setBackRunning(true);
    }

    @Override
    public void onActivitySaveInstanceState(Activity activity, Bundle outState) {

    }

        @Override
        public void onActivityDestroyed(Activity activity) {

    }
}

